function GetRequest() {   
			   var url = location.search; //获取url中"?"符后的字串   
			   var theRequest = new Object();   
			   if (url.indexOf("?") != -1) {   
			      var str = url.substr(1);   
			      strs = str.split("&");   
			      for(var i = 0; i < strs.length; i ++) {   
			         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);   
			      }   
  			 }   
   			return theRequest;   
		}   

		layui.use(['upload','element','table','form','layer'],function(){
			 var $ = layui.jquery
  		,upload = layui.upload
			,table = layui.table
			,layer = layui.layer
			,element =layui.element
			,form = layui.form
			var paperId = GetRequest().paperId;
			//添加问题
			$("#addQuestion").click(function(){
				layer.open({
					      type: 2,
					      title: '试卷编辑',
					      shadeClose: true,
					      
					     
					     //开启最大化最小化按钮
					      area: ['500px', '500px'],
					      content: "editQuestion.html?paperId="+paperId,
					      cancel: function(index, layero){ 
						  	paperDetil.reload()
						    layer.close(index)
							
						}    
			    	});
			})
			
			
			var paperDetil = table.render({
				
				elem:'#paperDetil',
				url:"http://localhost:8888/paper/getQuestionList/"+paperId,
				cols:[[
					  {field:'id', width:80, title: 'ID', sort: true}
			      ,{field:'title', edit:true, title: '问题'}
			      ,{field:'optionA',  edit:true,title: 'A'}
			      ,{field:'optionB', edit:true, title: 'B', sort: true}
			      ,{field:'optionC',  edit:true,title: 'C', sort: true}
			      ,{field:'optionD', edit:true, title: 'D', sort: true}
			      ,{fixed:'right',width:80,align:'center',title:"操作",toolbar:'#bar'}
					      
				]]
			});
			table.on('edit(paperDetil)', function(obj){ //注：edit是固定事件名，test是table原始容器的属性 lay-filter="对应的值"		  
			  $.ajax({	
			  	url:"http://localhost:8888/question/edit",
			  	type:'post',
			  	data:{'id':obj.data.id,
			  	 'optionA':obj.data.optionA,
			    'optionB':obj.data.optionB,
			    'optionC':obj.data.optionC,
			    'optionD':obj.data.optionD,
			  	'title':obj.data.title},
			  	success:function(){
			  		layer.msg("修改成功")
			  	}
			  })		 
			});
			
			table.on('tool(paperDetil)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
				  var data = obj.data; //获得当前行数据
				  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
				  var tr = obj.tr; //获得当前行 tr 的DOM对象
				 
				  if(layEvent === 'detail'){ //查看
				    //do somehing
				  } else if(layEvent === 'del'){ //删除
				    layer.confirm('真的删除行么', function(index){
				      obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
//				      console.log(data.id)
				      layer.close(index);
//				      向服务端发送删除指令
				      $.ajax({
				      	url:"http://localhost:8888/question/delete?id="+data.id,
				      	type:"get",
				      	success:function(data){
				      		layer.msg("删除成功")
				      		location.reload()
				      	}
				      })
				    });
				  } else if(layEvent === 'edit'){ //编辑
				    //do something				    
				    //同步更新缓存对应的值
				   //iframe窗
				 	
				  }
			});
  });
